﻿using MySql.Data.MySqlClient;
using NB.MGJ.Common.Utility;
using NB.MGJ.FrameWork;
using NB.MGJ.Model;
using NB.MGJ.Model.AntiFake;
using NB.MGJ.Model.Model;
using NB.MGJ.Model.SystemEntity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
namespace NB.MGJ.Service.AntiFake
{
    public class AppraiseListService
    {
        public BaseRepository _base = new BaseRepository();
	
	    #region  分页查询数据
		public PagedList<V_AppraiseList> GetACommentService(ref PagerModel page, string wsearch)
        {
			page.FldName = @"ID, ProductId, ProductName, NickName, CommentDate, CommentContent, IsConformed ";
			page.TblName = @" V_AppraiseList as A ";
			string StrCondition = "  1=1 ";
			if (!string.IsNullOrWhiteSpace(page.StrCondition)) {
				StrCondition = page.StrCondition + " and ViewDel=0 ";
			}
			page.StrCondition = StrCondition;
			if (string.IsNullOrEmpty(page.FldSort) || page.FldSort == "")
				page.FldSort = " A.ID  desc ";
		
            MySqlParameter[] parameters = _base.SqParameterRefactor(ref page);
			IEnumerable<V_AppraiseList> resultList = _base.ExecuteStoredProcedureCollection<V_AppraiseList>("Common_PageList", parameters);
			return new PagedList<V_AppraiseList>(resultList, page.Page, page.PageSize, 1, Convert.ToInt32(parameters[6].Value));
        }
		#endregion
	
		#region  删除
		public int DelAppraiseListService(int id,LogOnUserModel  model) {
			//AntiFake_Comment ap = new AntiFake_Comment();
			//ap.ViewDel = 1;
			//ap.ButtonId = id;
			//ap.CommentDate = DateTime.Now;
			//ap.ChangeDate = DateTime.Now;
			//ap.CreateDate = DateTime.Now;
			//ap.IsConformed = false;
			var sql = string.Format("UPDATE AntiFake_Comment SET `ViewDel` =1,  `ChangeLoginID` = '{0}',`ChangeDate` ='{1}' WHERE ID = '{2}'", model.UserID, DateTime.Now, id);
			return _base.ExecuteSql<int>(sql);
		}
		#endregion
	
		#region  反馈添加
		public int AddFeedBack(AntiFake_FeedBack model) {
			int rulset = _base.Insert<AntiFake_FeedBack>(model);
			return rulset;
		}
        //微信小程序反馈添加
        public int AddwxFeedBack(Sys_FeedBack model)
        {
            int rulset = _base.Insert<Sys_FeedBack>(model);
            return rulset;
        }
		#endregion
	}
}
